var $ = require("../../utils/Ajax.js");
Page({
  data: {
    FeedBack: ''
  },

  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: "意见反馈"
    })
  },

  onShow: function () {

  },

  // 输入意见反馈内容
  FeedBack: function(e){
    var FeedBack = e.detail.value.replace(/(^\s*)|(\s*$)/g, "");
    this.setData({
      FeedBack: FeedBack
    })
  },

  // 点击提交意见
  FeedSubmit: function(){
    var FeedBack = this.data.FeedBack;
    if (FeedBack.length < 15){
      wx.showToast({
        title: '内容不能小于十五字',
        icon: 'none',
        duration: 2000
      })
    }else{
      $.Ajax("api/x_feedback","POST",{
        content: FeedBack
      },function(res){
        if(res.s){
          wx.showToast({
            title: res.m,
            icon: 'none',
            duration: 1500
          })
          setTimeout(function(){
            wx.navigateBack({
              delta: 1
            })
          },1500)
        }
      })
    }
  }
})